import React, { Component } from "react"
import AddCounter from "./AddCounter"
import ReduceCounter  from "./ReduceCounter"

export class App extends Component {
    constructor() {
        super()

        this.state = {
            counter: 100,
        }
    }

    subCount(count) {
        this.setState({
            counter: this.state.counter + count,
        })
    }

    render() {
        const { counter } = this.state
        return (
            <div>
                <h2>当前计数: {counter}</h2>
                <AddCounter subClick={(count) => this.subCount(count)} />
                <ReduceCounter subClick={(count) => this.subCount(-count)} />
            </div>
        )
    }
}

export default App
